<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
    isActive: Boolean,
  },
});
</script>

<template>
  <view class="product-item">
    <image
      class="product-item-img"
      v-if="isActive"
      src="@/package/mall/static/vip-product.png"
    />

    <view class="product-item-content">
      <view
        class="product-item-name"
        :style="{ fontSize: isActive ? '36rpx' : '' }"
      >
        {{ info.name }}
      </view>
      <view
        class="product-item-price"
        :style="{ color: isActive ? '#fd4f4f' : '' }"
      >
        <text class="product-item-price2">¥</text>{{ info.price }}
      </view>
      <view class="product-item-desc">{{ info.desc }}</view>
    </view>

    <view class="product-item-like" v-if="info.is_recommend === 1">
      <image
        class="product-item-like2"
        src="@/package/mall/static/vip-like.png"
      />
      推荐
    </view>
  </view>
</template>

<style lang="scss">
.product-item {
  position: relative;
  height: 100%;
  border-radius: 20rpx;
  background-color: #fdfcf6;

  .product-item-img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  .product-item-content {
    position: relative;
    padding-top: 40rpx;
  }

  .product-item-name {
    margin-bottom: 20rpx;
    font-size: 30rpx;
    color: #965b1e;
    line-height: 50rpx;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .product-item-price {
    margin-bottom: 20rpx;
    font-size: 80rpx;
    color: #795021;
    line-height: 94rpx;
    text-align: center;
    font-weight: bold;
  }

  .product-item-price2 {
    font-size: 44rpx;
    line-height: 60rpx;
  }

  .product-item-desc {
    font-size: 26rpx;
    color: #965b1e;
    line-height: 36rpx;
    text-align: center;
  }

  .product-item-like {
    position: absolute;
    left: 0;
    top: -20rpx;
    display: flex;
    align-items: center;
    height: 44rpx;
    padding: 0 20rpx;
    font-size: 24rpx;
    color: #ffffff;
    font-weight: bold;
    border-radius: 22rpx 22rpx 22rpx 0;
    background: linear-gradient(90deg, #ff9d06, #fe6703);
  }

  .product-item-like2 {
    width: 32rpx;
    height: 32rpx;
    margin-right: 10rpx;
  }
}
</style>